var PAGE_SIZE = 20;

function createList(pageNo = 1, pageSize = 10) {

    let uid = $("#txtSearch").val();

    var matchData = {
    };
    if (!!uid) {
        matchData.uid = uid;
    }

    var start = (pageNo - 1) * pageSize;
    // 请求数据
    apiAdminGetRecord('adminGrantRecordModel', start, pageSize, matchData,
        function (data) {
            setTimeout(() => {
                $('#dataList').bootstrapTable('load', data.msg);
            }, 200)
        });
}

$(document).ready(function () {

    //数据表格初始化
    $('#dataList').bootstrapTable({
        striped: true, // 是否显示行间隔色
        pageNumber: 1, // 初始化加载第一页
        pagination: true, // 是否分页
        theadClasses: "thead-light",//这里设置表头样式
        sidePagination: 'server', // server:服务器端分页|client：前端分页
        pageSize: 10, // 单页记录数
        pageList: [10, 20, 30],
        totalField: "totalCount",
        dataField: "recordArr",
        buttonsClass: 'light',
        buttonsPrefix: 'btn',
        showRefresh: false,// 刷新按钮
        onPageChange: function (number, size) {
            createList(number, size);
        },
        queryParams: function (params) { // 上传服务器的参数
            let uid = $("#txtSearch").val();
            var temp = {//如果是在服务器端实现分页，limit、offset这两个参数是必须的
                limit: params.limit, // 每页显示数量
                offset: params.offset, // SQL语句起始索引
                uid: uid,
            };
            return temp;
        },
        columns: [{
            field: 'uid',
            title: '管理员ID',
            width: 150,
            align: "center",
            valign: "middle",
        },
        {
            field: 'gainUid',
            title: '赠送目标用户ID',
            width: 300,
            align: "center",
            valign: "middle",
        },
        {
            field: 'count',
            title: '赠送数量',
            width: 300,
            align: "center",
            valign: "middle",
        },
        {
            field: 'createTime',
            title: '赠送时间',
            width: 500,
            align: "center",
            valign: "middle",
            formatter: function (value) {
                if (!!value || value === 0) {
                    return new Date(value).toLocaleString();
                }
            }
        }]
    });
    createList();

    // $('#applyDateStr').datebox({ request: true });
    // $('#applyDateEnd').datebox({ request: true });

});